package com.edu.app.mapper.app.teacher;

import com.edu.app.bean.app.teacher.SysCustomerActFeedback;
import com.edu.app.util.AppBaseMapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface SysCustomerActFeedbackMapper extends AppBaseMapper<SysCustomerActFeedback> {
    @Select("SELECT T3.* FROM S_CUSTOMER T1 INNER JOIN S_CUSTOMER_ACTIVITY T2 ON T1.ID=T2.CUSTOMER_ID " +
            "INNER JOIN S_CUSTOMER_ACTIVITY_FEEDBACK T3 ON T3.CUSTOMER_ACTIVITY_ID = T2.ID WHERE T1.ID = #{id} ORDER BY T3.TIME DESC")
    List<SysCustomerActFeedback> getObjectListOrderByTime(Integer id);

    @Select("select t2.id from s_customer_activity t1 " +
            "inner join s_customer_activity_feedback t2 on t1.id = t2.customer_activity_id " +
            "where t1.customer_id = ${customer_id} and t1.activity_id = ${activity_id}")
    Integer getFeedbackIdWithCustomerAndActId(@Param("customer_id") Integer customer_id, @Param("activity_id") Integer activity_id);

    @Select("DELETE FROM S_CUSTOMER_ACTIVITY_FEEDBACK WHERE CUSTOMER_ACTIVITY_ID = #{id}")
    Integer deleteCustomerActFeedbackByActId(Integer id);
}
